﻿using System;
using System.ComponentModel;

using SBPweb.RIA.Shared.Contracts.Events;

using SBPweb.PROvibe.Server.Library.Services;
using SBPweb.PROvibe.Server.Library.Modularity;

using SBPweb.PROvibe.Server.Core.Services;

using SBPweb.PROvibe.Shared.Library.Base;
using SBPweb.PROvibe.Shared.Library.Components;

namespace SBPweb.PROvibe.Server.Core.Modularity
{

    public class CoreModule : ServerModuleBase
    {

        #region Fields

        private ConfigurationProviderService configurationService;

        #endregion

        #region Constructor logic

        public CoreModule()
            : base()
        {
            configurationService = new ConfigurationProviderService(this);
        }

        #endregion

        #region Methods
        
        protected override void OnServerContextAssigning()
        {
            base.OnServerContextAssigning();

            ServerContext.ServiceManager.RegisterService(configurationService);
        }

        protected override void OnInitializing(CancelEventArgs e)
        {
            base.OnInitializing(e);

            Modules.ServiceProvider.Contracts.IServiceProviderService isps = PublicServices.FirstByType<Modules.ServiceProvider.Contracts.IServiceProviderService>();
            isps.CreateServiceHost<ConfigurationProviderService, IConfigurationProviderService>(this, "ConfigurationProvider.svc");
            isps.CreateServiceHost<ContentContextProviderService, IContentContextProviderService>(this, "ContentContextProvider.svc");
        }

        #endregion

    }

}